{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 300,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import os\n",
    "os.chdir(\"E:\\pythonstudy\")\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "import seaborn as sns\n",
    "import matplotlib.pyplot as plt\n",
    "import datetime\n",
    "import math"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 301,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "data=pd.read_csv(\"day.csv\")#导入数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 302,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "#将几个类别特征用独热化\n",
    "one_note=data[['season','holiday','weathersit','weekday']]\n",
    "from sklearn.preprocessing import OneHotEncoder\n",
    "enc = OneHotEncoder()\n",
    "enc.fit(one_note)\n",
    "one_note_h=enc.transform(one_note).toarray()\n",
    "\n",
    "one_note_list = ('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P')\n",
    "df = pd.DataFrame(one_note_h,columns=one_note_list ) ;\n",
    "df['instant']=data['instant']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 303,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "train = data[data['yr']==0]\n",
    "test = data[data['yr']==1]\n",
    "#分开测试值与训练集"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 304,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "y_train = train['cnt'].values  #将目标值y取出来，其他均为x\n",
    "X_train = train.drop('cnt',axis =1)#drop函数默认删除行，列需要加axis = 1\n",
    "# 以上为训练集\n",
    "y_test = test['cnt'].values  \n",
    "X_test = test.drop('cnt',axis =1)\n",
    "# 以上为测试集"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 307,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYoAAAENCAYAAAARyyJwAAAABHNCSVQICAgI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UV5oolFJKeaWJQimllFeaKJRSSnmliUIp\npZRX/w8NDFJfzdwPowAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x268bede72e8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig = plt.figure()\n",
    "# sns.distplot(train[train['season']==1].cnt.values,bins=30,kde=True)\n",
    "# sns.distplot(train[train['season']==2].cnt.values,bins=30,kde=True)\n",
    "# sns.distplot(train[train['season']==3].cnt.values,bins=30,kde=True)\n",
    "# sns.distplot(train[train['season']==4].cnt.values,bins=30,kde=True)\n",
    "sns.distplot(train.cnt.values,bins=30,kde=True)\n",
    "plt.xlabel('the num of shared bicyle drawed by seasons',fontsize=13)\n",
    "plt.show()\n",
    "#画出y值的分布图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 299,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "X_train1 = X_train.drop(['instant','atemp','weathersit','mnth','season','holiday','weekday','workingday','casual','registered','dteday','yr'], axis=1)   \n",
    "X_test1 = X_test.drop(['instant','atemp','weathersit','mnth','season','holiday','weekday','workingday','casual','registered','dteday','yr'], axis=1)  \n",
    "#删除不必要的特征"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 287,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>temp</th>\n",
       "      <th>hum</th>\n",
       "      <th>windspeed</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.344167</td>\n",
       "      <td>0.805833</td>\n",
       "      <td>0.160446</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.363478</td>\n",
       "      <td>0.696087</td>\n",
       "      <td>0.248539</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.196364</td>\n",
       "      <td>0.437273</td>\n",
       "      <td>0.248309</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.200000</td>\n",
       "      <td>0.590435</td>\n",
       "      <td>0.160296</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.226957</td>\n",
       "      <td>0.436957</td>\n",
       "      <td>0.186900</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       temp       hum  windspeed\n",
       "0  0.344167  0.805833   0.160446\n",
       "1  0.363478  0.696087   0.248539\n",
       "2  0.196364  0.437273   0.248309\n",
       "3  0.200000  0.590435   0.160296\n",
       "4  0.226957  0.436957   0.186900"
      ]
     },
     "execution_count": 287,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X_train1.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 288,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "D:\\ProgramData\\Anaconda3\\lib\\site-packages\\sklearn\\utils\\validation.py:475: DataConversionWarning: Data with input dtype int64 was converted to float64 by StandardScaler.\n",
      "  warnings.warn(msg, DataConversionWarning)\n"
     ]
    }
   ],
   "source": [
    "from sklearn.preprocessing import StandardScaler\n",
    "from sklearn import preprocessing\n",
    "#对X进行归一化\n",
    "min_max_scaler = preprocessing.MinMaxScaler()\n",
    "X_train2=min_max_scaler.fit_transform(X_train1)\n",
    "X_test2=min_max_scaler.fit_transform(X_test1)\n",
    "\n",
    "# ss_X = StandardScaler()\n",
    "# X_train2 = ss_X.fit_transform(X_train1)\n",
    "# X_test2 = ss_X.fit_transform(X_test1)\n",
    "# X_train2 = preprocessing.scale(X_train1)\n",
    "# X_test2 = preprocessing.scale(X_test1)\n",
    "# y_train = preprocessing.scale(y_train)\n",
    "# y_test = preprocessing.scale(y_test)\n",
    "\n",
    "#对Y进行标准化\n",
    "ss_y = StandardScaler()\n",
    "y_train = ss_y.fit_transform(y_train.reshape(-1, 1))\n",
    "y_test = ss_y.fit_transform(y_test.reshape(-1, 1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 289,
   "metadata": {},
   "outputs": [],
   "source": [
    "#将前面的独热编码加到归一化的X中去\n",
    "X_train2=pd.DataFrame(X_train2,columns=('temp','hum','windspeed') ) \n",
    "X_test2=pd.DataFrame(X_test2,columns=('temp','hum','windspeed') ) \n",
    "X_train2['instant']=X_train2.index.values+1\n",
    "X_test2['instant']=X_test2.index.values+366\n",
    "X_train2 = pd.merge(X_train2,df,how='left')\n",
    "X_test2 = pd.merge(X_test2,df,how='left')\n",
    "X_train2 = X_train2.drop(['instant'],axis=1)\n",
    "X_test2 = X_test2.drop(['instant'],axis=1)\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 290,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>coef</th>\n",
       "      <th>columns</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>[2.445665835440917]</td>\n",
       "      <td>temp</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>[0.48303542932217075]</td>\n",
       "      <td>G</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>[0.42643400450571545]</td>\n",
       "      <td>D</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>[0.2532992512946753]</td>\n",
       "      <td>H</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>[0.14693152925433428]</td>\n",
       "      <td>B</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>[0.13121653848679665]</td>\n",
       "      <td>E</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>[0.052403409150248326]</td>\n",
       "      <td>C</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>[0.047726718343174546]</td>\n",
       "      <td>O</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>[0.04384090864214111]</td>\n",
       "      <td>P</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>[0.01780661500745364]</td>\n",
       "      <td>L</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>[-0.0011784153776949607]</td>\n",
       "      <td>N</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>[-0.01624332580581514]</td>\n",
       "      <td>M</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>[-0.019049535503085357]</td>\n",
       "      <td>K</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>[-0.07290296530617402]</td>\n",
       "      <td>J</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>[-0.13121653848679704]</td>\n",
       "      <td>F</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>[-0.6257689429102968]</td>\n",
       "      <td>A</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>[-0.6371646069212806]</td>\n",
       "      <td>hum</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>[-0.7363346806168465]</td>\n",
       "      <td>I</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>[-0.813787726175612]</td>\n",
       "      <td>windspeed</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                        coef    columns\n",
       "0        [2.445665835440917]       temp\n",
       "9      [0.48303542932217075]          G\n",
       "6      [0.42643400450571545]          D\n",
       "10      [0.2532992512946753]          H\n",
       "4      [0.14693152925433428]          B\n",
       "7      [0.13121653848679665]          E\n",
       "5     [0.052403409150248326]          C\n",
       "17    [0.047726718343174546]          O\n",
       "18     [0.04384090864214111]          P\n",
       "14     [0.01780661500745364]          L\n",
       "16  [-0.0011784153776949607]          N\n",
       "15    [-0.01624332580581514]          M\n",
       "13   [-0.019049535503085357]          K\n",
       "12    [-0.07290296530617402]          J\n",
       "8     [-0.13121653848679704]          F\n",
       "3      [-0.6257689429102968]          A\n",
       "1      [-0.6371646069212806]        hum\n",
       "11     [-0.7363346806168465]          I\n",
       "2       [-0.813787726175612]  windspeed"
      ]
     },
     "execution_count": 290,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 线性回归\n",
    "#class sklearn.linear_model.LinearRegression(fit_intercept=True, normalize=False, copy_X=True, n_jobs=1)\n",
    "from sklearn.linear_model import LinearRegression\n",
    "\n",
    "# 使用默认配置初始化\n",
    "lr = LinearRegression()\n",
    "\n",
    "# 训练模型参数\n",
    "lr.fit(X_train2, y_train)\n",
    "\n",
    "# 预测\n",
    "y_test_pred_lr = lr.predict(X_test2)\n",
    "y_train_pred_lr = lr.predict(X_train2)\n",
    "columns=X_train2.columns\n",
    "\n",
    "# 看看各特征的权重系数，系数的绝对值大小可视为该特征的重要性\n",
    "fs = pd.DataFrame({\"columns\":list(columns), \"coef\":list((lr.coef_.T))})\n",
    "fs.sort_values(by=['coef'],ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 291,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAekAAAFsCAYAAADos0H8AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4wLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvpW3flQAAHWZJREFUeJzt3XuUXGWZ7/HvQ9IShkC4dTAQMYAg\ndzrYRDIIBqOAggTPqOhBCItAFHUW6ugochxa1KMuUZccGZZRERCU28jAeDkDJ8JEOAqTOJGLQROF\nHBNiaIJcgnJJ85w/anfsJN3pSnd195uu72etWlW19669n3p3d//63XvXW5GZSJKk8mwz0gVIkqTe\nGdKSJBXKkJYkqVCGtCRJhTKkJUkqlCEtSVKhDGk1vYh4MCJmjHQdIyki3hYRf4iItRExdRi3uzYi\n9ulj3lkRcVeDtvNIRLyxEeuShpMhrVGttz/OG//xz8yDM/POftYzJSIyIsYOUakj7RLgg5k5PjP/\na+OZ1Xt/tgrVlRHxlYgYM9iNVtv7/WDXI41WhrRUgALC/5XAg/0sc3hmjgdeD5wGnD3kVUlNzpBW\n0+vZ246IaRGxMCKejojVEfGVarEF1f2TVW9yekRsExH/IyKWR8RjEXF1REzosd4zq3lrIuJTG22n\nIyJuiohrIuJp4Kxq2z+PiCcjYlVEfD0iXtZjfRkR74+IpRHxTER8JiL2rV7zdETc0HP5jd5jr7VG\nxLYRsRYYA/wqIn7XX3tl5jLgbqCtx/onRMS3q7pXRsRnu3vaEfGqiPiPiHgqIh6PiO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qLr300gFt\nfyTUc3X3fcDUXqa/YUgqkiSNiO22247FixcDMHv2bC677DIuvPDCLV7Pt771rUaX1hDt7e0bhPZQ\n6OrqYsyYMQ1bnyOOSZI2MX36dFauXLn++Ze+9CWOPPJIDjvsMC666CIAnn32WU466SQOP/xwDjnk\nEK6//nqg1ovtHgL6O9/5Dvvvvz+vf/3rufvuu9ev76yzzuKmm/46zMb48eMBWLt2LTNnzuSII47g\n0EMP5ZZbbtmktlWrVnHsscfS1tbGIYccws9+9rO63tOdd97JySefDEBHRwdnn302M2bMYJ999tmg\nd33NNdcwbdo02traeO9730tXVxcA5513Hu3t7Rx88MHr2wBqQ15ffPHFvO51r+PGG2+sq5Z6DevY\n3ZKk8nV1dTF//nzmzJkDwG233cbSpUu59957yUxOOeUUFixYQGdnJ3vssQc/+tGPAHjqqac2WM+q\nVau46KKLWLRoERMmTOC4445j6tRNDsxuYNy4cdx8883suOOOPP744xx11FGccsopG1yA9b3vfY8T\nTjiBCy+8kK6uLv785z8P6H0+9NBD3HHHHTzzzDO8+tWv5rzzzmPZsmVcf/313H333bS0tPD+97+f\na6+9ljPPPJPPfe5z7LLLLnR1dTFz5kzuu+8+DjvssPV133XXXQOqY3MMaUkSAH/5y19oa2vjkUce\n4TWveQ1vetObgFpI33bbbesDdu3atSxdupRjjjmGj370o3z84x/n5JNP5phjjtlgfffccw8zZsyg\n+5M9p512Gr/97W83W0Nm8slPfpIFCxawzTbbsHLlSlavXs3LX/7y9csceeSRnH322bz44ouceuqp\ntLUNbFTqk046iW233ZZtt92WiRMnsnr1aubPn8+iRYs48sgj17fJxIkTAbjhhhuYN28e69atY9Wq\nVfz6179eH9KnnXbagGroj4e7JUnAX89JL1++nBdeeIHLLrsMqAXnBRdcwOLFi1m8eDHLli1jzpw5\n7L///ixatIhDDz2UCy64gIsvvniTdfb1EaSxY8fy0ksvrV//Cy+8AMC1115LZ2cnixYtYvHixey+\n++6bfM742GOPZcGCBey5556cccYZXH311QN6v9tuu+36x2PGjG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8KfMfBXwVeCLw1vl0NuCn/Hre+z/bw1r\nkcPjSuDEzcx/M7BfdZsLXD4MNRXPkB4CmbkkM5txZLUN1NkOzTC87CzgqurxVcCpI1jLcKpn3/Zs\nm5uAmRHR20BJW7Nm+BnvV2YuAJ7YzCKzgKuz5hfAThExaXiqK5chPbISuC0iFlXDpzajPYE/9Hi+\nopo2muyemasAqvuJfSw3LiIWRsQvImI0BHk9+3b9Mpm5DngK2HVYqhs+9f6M/111mPemiHhFL/NH\nu2b4W7DFBjMsaFOLiP8DvLyXWRdm5i11rubozHw0IiYCt0fEQ9V/m1uNBrRDXcPLlm5z7bAFq9mr\n+nnYB/hpRNyfmb9rTIUjop59Oyr2fz/qeY//Bnw/M5+PiPdRO7rwhiGvrCzN8LOwxQzpAcrMNzZg\nHY9W949FxM3UDottVSHdgHYYFcPLbq4dImJ1REzKzFXV4bvH+lhH98/D7yPiTmAqsDWHdD37tnuZ\nFRExFpjA5g+Jbo36bYfMXNPj6TcZhefm6zAq/hY0moe7R0hEbB8RO3Q/Bo6ndqFVs2mG4WVvBWZX\nj2cDmxxhiIidI2Lb6vFuwNHAr4etwqFRz77t2TZvB36ao2+EpX7bYaNzr6cAS4axvlLcCpxZXeV9\nFPBU92mippaZ3hp8A95G7b/C54HVwL9X0/cAflw93gf4VXV7kNrh4RGvfbjboXr+FuC31HqNo7Ed\ndqV2VffS6n6Xano78K3q8d8C91c/D/cDc0a67ga99032LXAxcEr1eBxwI7AMuBfYZ6RrHqF2+Hz1\nd+BXwB3AASNd8xC0wfeBVcCL1d+FOcD7gPdV84PaVfC/q34H2ke65hJuDgsqSVKhPNwtSVKhDGlJ\nkgplSEuSVChDWpKkQhnSkiQVypCWJKlQhrQkSYX6/24lIilRMArmAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x268bede38d0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#在训练集上观察预测残差的分布，看是否符合模型假设：噪声为0均值的高斯噪声\n",
    "f, ax = plt.subplots(figsize=(7, 5)) \n",
    "f.tight_layout() \n",
    "ax.hist(y_train - y_train_pred_lr,bins=40, label='Residuals Linear', color='b', alpha=.5); \n",
    "ax.set_title(\"Histogram of Residuals\") \n",
    "ax.legend(loc='best')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 292,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "D:\\ProgramData\\Anaconda3\\lib\\site-packages\\sklearn\\utils\\validation.py:578: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().\n",
      "  y = column_or_1d(y, warn=True)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "array([ 2.30284364, -0.56128144, -0.78773808, -0.78271066,  0.03406457,\n",
       "       -0.02847267,  0.29274204, -0.11667933, -0.36769739,  0.33737939,\n",
       "        0.09218764, -0.91394375, -0.14433616, -0.08892638, -0.04935169,\n",
       "       -0.08393606, -0.06818935, -0.022022  , -0.02761508])"
      ]
     },
     "execution_count": 292,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 线性模型，随机梯度下降优化模型参数\n",
    "# 随机梯度下降一般在大数据集上应用，其实本项目不适合用\n",
    "from sklearn.linear_model import SGDRegressor\n",
    "\n",
    "# 使用默认配置初始化线\n",
    "sgdr = SGDRegressor(max_iter=1000)\n",
    "\n",
    "# 训练：参数估计\n",
    "sgdr.fit(X_train2, y_train)\n",
    "\n",
    "# 预测\n",
    "#sgdr_y_predict = sgdr.predict(X_test)\n",
    "\n",
    "sgdr.coef_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 293,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The value of default measurement of SGDRegressor on test is 0.7142072733254463\n",
      "The value of default measurement of SGDRegressor on train is 0.8057917002992457\n"
     ]
    }
   ],
   "source": [
    "# 使用SGDRegressor模型自带的评估模块(评价准则为r2_score)，并输出评估结果\n",
    "print ('The value of default measurement of SGDRegressor on test is', sgdr.score(X_test2, y_test))\n",
    "print ('The value of default measurement of SGDRegressor on train is', sgdr.score(X_train2, y_train))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 294,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The r2 score of RidgeCV on test is -2.8074322557802746e+23\n",
      "The r2 score of RidgeCV on train is -2.878325873537443e+23\n",
      "the most alph 1e-25\n"
     ]
    }
   ],
   "source": [
    "#岭回归及最佳参数选择\n",
    "#class sklearn.linear_model.RidgeCV(alphas=(0.1, 1.0, 10.0), fit_intercept=True, \n",
    "#                                  normalize=False, scoring=None, cv=None, gcv_mode=None, \n",
    "#                                  store_cv_values=False)\n",
    "from sklearn.linear_model import  RidgeCV\n",
    "#设置超参数（正则参数）范围\n",
    "alphas = [0.0000000000000000000000001, 5, 5.95, 5.97]\n",
    "\n",
    "ridge = RidgeCV(alphas=alphas, store_cv_values=True)  \n",
    "\n",
    "\n",
    "#模型训练\n",
    "ridge.fit(X_train2, y_train)    \n",
    "\n",
    "#预测\n",
    "y_test_pred_ridge = ridge.predict(X_test2)\n",
    "y_train_pred_ridge = ridge.predict(X_train2)\n",
    "\n",
    "from sklearn.metrics import r2_score\n",
    "# 评估，使用r2_score评价模型在测试集和训练集上的性能\n",
    "print ( 'The r2 score of RidgeCV on test is', r2_score(y_test, y_test_pred_ridge))\n",
    "print ( 'The r2 score of RidgeCV on train is', r2_score(y_train, y_train_pred_ridge))\n",
    "print ('the most alph',ridge.alpha_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 295,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZIAAAEKCAYAAAA4t9PUAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB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902gM7Q0dEtxN8iN8J6STek2+lAdIRiUjNvErw+sdHBI8Svu3uu8zsf4ErCf7CzgHeBw6F\n1vk7wWBZ7O4fmdlaYD3Bx9OvOMXnHAXONbPVoe1MPUNdc4H/NbObgKWh9U+4PFSDSFTp6b8iETKz\nNu5ebGadCR6lXBwKmZYEf7lfXNPHtJtZsbu3qaO63gaudfcDdbE9kVPREYlI5P5mZh2AZOBH7r4L\nwN2PmdkPCX6fdkF9FhQ6/TZTISL1QUckIiISEV1sFxGRiChIREQkIgoSERGJiIJEREQioiAREZGI\nKEhERCQi/x8t5kIiSE7nKgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x268bb589208>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "alpha is: 1e-25\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>coef_lr</th>\n",
       "      <th>coef_ridge</th>\n",
       "      <th>columns</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>[2.445665835440917]</td>\n",
       "      <td>[35265708032.0]</td>\n",
       "      <td>temp</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>[0.48303542932217075]</td>\n",
       "      <td>[-419396845568.0]</td>\n",
       "      <td>G</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>[0.42643400450571545]</td>\n",
       "      <td>[-315982086144.0]</td>\n",
       "      <td>D</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>[0.2532992512946753]</td>\n",
       "      <td>[456071839744.0]</td>\n",
       "      <td>H</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>[0.14693152925433428]</td>\n",
       "      <td>[-354250915840.0]</td>\n",
       "      <td>B</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>[0.13121653848679665]</td>\n",
       "      <td>[-88665489408.0]</td>\n",
       "      <td>E</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>[0.052403409150248326]</td>\n",
       "      <td>[224428818432.0]</td>\n",
       "      <td>C</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>[0.047726718343174546]</td>\n",
       "      <td>[-56061067264.0]</td>\n",
       "      <td>O</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>[0.04384090864214111]</td>\n",
       "      <td>[29259464704.0]</td>\n",
       "      <td>P</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>[0.01780661500745364]</td>\n",
       "      <td>[38965084160.0]</td>\n",
       "      <td>L</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>[-0.0011784153776949607]</td>\n",
       "      <td>[79230402560.0]</td>\n",
       "      <td>N</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>[-0.01624332580581514]</td>\n",
       "      <td>[137212461056.0]</td>\n",
       "      <td>M</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>[-0.019049535503085357]</td>\n",
       "      <td>[-189205053440.0]</td>\n",
       "      <td>K</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>[-0.07290296530617402]</td>\n",
       "      <td>[-10963910656.0]</td>\n",
       "      <td>J</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>[-0.13121653848679704]</td>\n",
       "      <td>[88665489408.0]</td>\n",
       "      <td>F</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>[-0.6257689429102968]</td>\n",
       "      <td>[458689085440.0]</td>\n",
       "      <td>A</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>[-0.6371646069212806]</td>\n",
       "      <td>[11167334400.0]</td>\n",
       "      <td>hum</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>[-0.7363346806168465]</td>\n",
       "      <td>[-42022731776.0]</td>\n",
       "      <td>I</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>[-0.813787726175612]</td>\n",
       "      <td>[78370570240.0]</td>\n",
       "      <td>windspeed</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     coef_lr         coef_ridge    columns\n",
       "0        [2.445665835440917]    [35265708032.0]       temp\n",
       "9      [0.48303542932217075]  [-419396845568.0]          G\n",
       "6      [0.42643400450571545]  [-315982086144.0]          D\n",
       "10      [0.2532992512946753]   [456071839744.0]          H\n",
       "4      [0.14693152925433428]  [-354250915840.0]          B\n",
       "7      [0.13121653848679665]   [-88665489408.0]          E\n",
       "5     [0.052403409150248326]   [224428818432.0]          C\n",
       "17    [0.047726718343174546]   [-56061067264.0]          O\n",
       "18     [0.04384090864214111]    [29259464704.0]          P\n",
       "14     [0.01780661500745364]    [38965084160.0]          L\n",
       "16  [-0.0011784153776949607]    [79230402560.0]          N\n",
       "15    [-0.01624332580581514]   [137212461056.0]          M\n",
       "13   [-0.019049535503085357]  [-189205053440.0]          K\n",
       "12    [-0.07290296530617402]   [-10963910656.0]          J\n",
       "8     [-0.13121653848679704]    [88665489408.0]          F\n",
       "3      [-0.6257689429102968]   [458689085440.0]          A\n",
       "1      [-0.6371646069212806]    [11167334400.0]        hum\n",
       "11     [-0.7363346806168465]   [-42022731776.0]          I\n",
       "2       [-0.813787726175612]    [78370570240.0]  windspeed"
      ]
     },
     "execution_count": 295,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#岭回归参数选择可视化\n",
    "mse_mean = np.mean(ridge.cv_values_, axis = 0)\n",
    "plt.plot(np.log10(alphas), mse_mean.reshape(len(alphas),1)) \n",
    "\n",
    "plt.xlabel('log(alpha)')\n",
    "plt.ylabel('mse')\n",
    "plt.show()\n",
    "\n",
    "print ('alpha is:', ridge.alpha_)\n",
    "\n",
    "# 看看各特征的权重系数，系数的绝对值大小可视为该特征的重要性\n",
    "fs = pd.DataFrame({\"columns\":list(columns), \"coef_lr\":list((lr.coef_.T)), \"coef_ridge\":list((ridge.coef_.T))})\n",
    "fs.sort_values(by=['coef_lr'],ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 296,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The r2 score of LassoCV on test is 0.6919131166982548\n",
      "The r2 score of LassoCV on train is 0.7931961737950308\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "D:\\ProgramData\\Anaconda3\\lib\\site-packages\\sklearn\\linear_model\\coordinate_descent.py:1094: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().\n",
      "  y = column_or_1d(y, warn=True)\n"
     ]
    }
   ],
   "source": [
    "#Lasso回归\n",
    "from sklearn.linear_model import LassoCV\n",
    "\n",
    "#生成一个LassoCV实例\n",
    "#lasso = LassoCV(alphas=alphas)  \n",
    "lasso = LassoCV()  \n",
    "\n",
    "#训练（内含CV）\n",
    "lasso.fit(X_train2, y_train)  \n",
    "#测试\n",
    "y_test_pred_lasso = lasso.predict(X_test2)\n",
    "y_train_pred_lasso = lasso.predict(X_train2)\n",
    "\n",
    "\n",
    "# 评估，使用r2_score评价模型在测试集和训练集上的性能\n",
    "print ('The r2 score of LassoCV on test is', r2_score(y_test, y_test_pred_lasso))\n",
    "print ('The r2 score of LassoCV on train is', r2_score(y_train, y_train_pred_lasso))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 297,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEKCAYAAAD9xUlFAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4wLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvpW3flQAAIABJREFUeJzt3XmcVPWZ7/HP03uzb80OAgIiqIg2\noKIGYxLRMXrNxBg17obcSZwkM0luTGLiNc7mmDszGWPGEMUlEY1G45K4x4VowqqA0IhiI3TTCA0N\n3fRey3P/qKJtSTdd0H36VHV/369Xveqcql/VeY5H6tvn9zuLuTsiIiIAWWEXICIi6UOhICIiLRQK\nIiLSQqEgIiItFAoiItJCoSAiIi0UCiIi0kKhICIiLRQKIiLSIifsAg7XsGHDfMKECWGXISKSUVav\nXr3b3Ys6apdxoTBhwgRWrVoVdhkiIhnFzLam0k7dRyIi0kKhICIiLRQKIiLSQqEgIiItFAoiItJC\noSAiIi0UCiIi0kKhICKSAX760nusKdsX+HIy7uQ1EZHe5s+bd/OfL71L3J0Txw0KdFnaUxARSWPN\n0Tg3Pbmeo4b24e/mHx348rSnICKSxn75p1JKK+u495rZFORmB7487SmIiKSp8r313PHye5x73EjO\nOmZ4tywzsFAws8VmtsvM1h+izXwzW2NmG8zstaBqERHJRLc8XUKWGT88f3q3LTPIPYX7gAXtvWlm\ng4CfAxe4+wzg4gBrERHJKE+treDFkp184+wpjB5U2G3LDSwU3H0pUHWIJpcBj7v7tmT7XUH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64H9fumMZhERadHju49ERCR1CgUREWmhUBAR\nkRYKBRERaaFQEBGRFgoF6TXMrLaTn/9t8ozRQ7V59VBX5Uy1zUHti8zsuVTbi3SGQkEkBWY2A8h2\n99LuXra7VwI7zGxedy9beh+FgvQ6lnC7ma1P3hfgkuTrWWb28+R1+H9vZs+Y2eeTH7ucVmeTmtn/\nJC9AtsHMbmlnObVm9v/M7E0z+6OZFbV6+2IzW2Fm75rZGcn2E8zsT8n2b5rZaa3aP5GsQSRQCgXp\njT4HnAjMBD4F3J68rszngAnA8cD1wKmtPjMPWN1q/gfuXgycAHzCzE5oYzl9gTfd/STgNT5+naoc\nd58DfLPV67uATyfbXwL8d6v2q4AzDn9VRQ5Pj7ggnshhOh14yN1jwE4zew2YnXz9UXePAx+a2Sut\nPjMKqGw1/4XkZaNzku9NJ3H5kdbiwG+S078GHm/13oHp1SSCCCAX+JmZnQjEgKmt2u8icYkGkUAp\nFKQ3auuSyYd6HaABKAAws4nAt4HZ7r7XzO478F4HWl9Tpin5HOOjf4f/QOI6PTNJ7MU3tmpfkKxB\nJFDqPpLeaClwiZllJ/v5zwRWAK8Df5scWxjBxy9BvhGYnJweANQB1cl257aznCzgwJjEZcnvP5SB\nwI7knsoVJG4XecBUMvdqpJJBtKcgvdHvSIwXrCXx1/v/cfcPzewx4GwSP77vAsuB6uRn/kAiJF5y\n97Vm9haJq4SWAm+0s5w6YIaZrU5+zyUd1PVz4DEzuxh4Jfn5A85K1iASKF0lVaQVM+vn7rVmNpTE\n3sO8ZGAUkvihnpcci0jlu2rdvV8X1bUUuNAT990WCYz2FEQ+7vdmNgjIA2519w8B3L3BzG4mcQ/f\nbd1ZULKL6z8UCNIdtKcgIiItNNAsIiItFAoiItJCoSAiIi0UCiIi0kKhICIiLRQKIiLS4v8DuZmU\nqU7UgxEAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x268beed39b0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "alpha is: 0.007194794096521699\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>coef_lasso</th>\n",
       "      <th>coef_lr</th>\n",
       "      <th>coef_ridge</th>\n",
       "      <th>columns</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2.057699</td>\n",
       "      <td>[2.445665835440917]</td>\n",
       "      <td>[35265708032.0]</td>\n",
       "      <td>temp</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>0.334365</td>\n",
       "      <td>[0.48303542932217075]</td>\n",
       "      <td>[-419396845568.0]</td>\n",
       "      <td>G</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>0.191484</td>\n",
       "      <td>[0.42643400450571545]</td>\n",
       "      <td>[-315982086144.0]</td>\n",
       "      <td>D</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>[0.2532992512946753]</td>\n",
       "      <td>[456071839744.0]</td>\n",
       "      <td>H</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>-0.000000</td>\n",
       "      <td>[0.14693152925433428]</td>\n",
       "      <td>[-354250915840.0]</td>\n",
       "      <td>B</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>[0.13121653848679665]</td>\n",
       "      <td>[-88665489408.0]</td>\n",
       "      <td>E</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>[0.052403409150248326]</td>\n",
       "      <td>[224428818432.0]</td>\n",
       "      <td>C</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>0.008911</td>\n",
       "      <td>[0.047726718343174546]</td>\n",
       "      <td>[-56061067264.0]</td>\n",
       "      <td>O</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>[0.04384090864214111]</td>\n",
       "      <td>[29259464704.0]</td>\n",
       "      <td>P</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>[0.01780661500745364]</td>\n",
       "      <td>[38965084160.0]</td>\n",
       "      <td>L</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>[-0.0011784153776949607]</td>\n",
       "      <td>[79230402560.0]</td>\n",
       "      <td>N</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>-0.000000</td>\n",
       "      <td>[-0.01624332580581514]</td>\n",
       "      <td>[137212461056.0]</td>\n",
       "      <td>M</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>-0.000000</td>\n",
       "      <td>[-0.019049535503085357]</td>\n",
       "      <td>[-189205053440.0]</td>\n",
       "      <td>K</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>-0.021254</td>\n",
       "      <td>[-0.07290296530617402]</td>\n",
       "      <td>[-10963910656.0]</td>\n",
       "      <td>J</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>-0.000000</td>\n",
       "      <td>[-0.13121653848679704]</td>\n",
       "      <td>[88665489408.0]</td>\n",
       "      <td>F</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>-0.836353</td>\n",
       "      <td>[-0.6257689429102968]</td>\n",
       "      <td>[458689085440.0]</td>\n",
       "      <td>A</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>-0.000000</td>\n",
       "      <td>[-0.6371646069212806]</td>\n",
       "      <td>[11167334400.0]</td>\n",
       "      <td>hum</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>-0.909656</td>\n",
       "      <td>[-0.7363346806168465]</td>\n",
       "      <td>[-42022731776.0]</td>\n",
       "      <td>I</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>-0.423448</td>\n",
       "      <td>[-0.813787726175612]</td>\n",
       "      <td>[78370570240.0]</td>\n",
       "      <td>windspeed</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    coef_lasso                   coef_lr         coef_ridge    columns\n",
       "0     2.057699       [2.445665835440917]    [35265708032.0]       temp\n",
       "9     0.334365     [0.48303542932217075]  [-419396845568.0]          G\n",
       "6     0.191484     [0.42643400450571545]  [-315982086144.0]          D\n",
       "10    0.000000      [0.2532992512946753]   [456071839744.0]          H\n",
       "4    -0.000000     [0.14693152925433428]  [-354250915840.0]          B\n",
       "7     0.000000     [0.13121653848679665]   [-88665489408.0]          E\n",
       "5     0.000000    [0.052403409150248326]   [224428818432.0]          C\n",
       "17    0.008911    [0.047726718343174546]   [-56061067264.0]          O\n",
       "18    0.000000     [0.04384090864214111]    [29259464704.0]          P\n",
       "14    0.000000     [0.01780661500745364]    [38965084160.0]          L\n",
       "16    0.000000  [-0.0011784153776949607]    [79230402560.0]          N\n",
       "15   -0.000000    [-0.01624332580581514]   [137212461056.0]          M\n",
       "13   -0.000000   [-0.019049535503085357]  [-189205053440.0]          K\n",
       "12   -0.021254    [-0.07290296530617402]   [-10963910656.0]          J\n",
       "8    -0.000000    [-0.13121653848679704]    [88665489408.0]          F\n",
       "3    -0.836353     [-0.6257689429102968]   [458689085440.0]          A\n",
       "1    -0.000000     [-0.6371646069212806]    [11167334400.0]        hum\n",
       "11   -0.909656     [-0.7363346806168465]   [-42022731776.0]          I\n",
       "2    -0.423448      [-0.813787726175612]    [78370570240.0]  windspeed"
      ]
     },
     "execution_count": 297,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mses = np.mean(lasso.mse_path_, axis = 1)\n",
    "plt.plot(np.log10(lasso.alphas_), mses) \n",
    "#plt.plot(np.log10(lasso.alphas_)*np.ones(3), [0.3, 0.4, 1.0])\n",
    "plt.xlabel('log(alpha)')\n",
    "plt.ylabel('mse')\n",
    "plt.show()    \n",
    "            \n",
    "print ('alpha is:', lasso.alpha_)\n",
    "\n",
    "# 看看各特征的权重系数，系数的绝对值大小可视为该特征的重要性\n",
    "fs = pd.DataFrame({\"columns\":list(columns), \"coef_lr\":list((lr.coef_.T)), \"coef_ridge\":list((ridge.coef_.T)), \"coef_lasso\":list((lasso.coef_.T))})\n",
    "fs.sort_values(by=['coef_lr'],ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
